#include <stdio.h>
#include <stdlib.h>

int is_leap(int);

int main()
{
    char day_list[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int month = 0, day = 0, year = 0;
    int sum = 0;
    scanf("%d %d", &year, &sum);
    if(is_leap(year))day_list[1]++;
    for(month = 0; day_list[month] < sum; month++)sum -= day_list[month];
    month++;
    day = sum;
    printf("%d-%d-%d\n", year, month, day);
    return 0;
}

int is_leap(int year)
{
    if(year % 100)
    {
        return !(year % 4);
    }
    else
    {
        return !(year % 400);
    }
}